import { createStore } from 'vuex'
import user from './user'
import request from '../network/request'
export default createStore({
  state: {
    treeData:[]
  },
  mutations: {
    setTreeData(state,payload){
        state.treeData=payload
    }
  },
  actions: {
    getTreeData(context,payload){
     return new Promise((resolve,reject)=>{
      request({
        url:'/menu/list',
        method:'get',
        params:{
        }
    }).then(res=>{
      res = res.data.data.tree
    
      context.commit('setTreeData',res)
      console.log(context.state.treeData)
      resolve(res)
    },err=>{
       reject(err)
    })
     })
    }
  },
  modules: {
    user
  }
})
